package util;

import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;

import org.junit.Test;

import br.com.linhadotempo.util.MicroBlogging;

import twitter4j.Paging;
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;

public class testTwitterApp extends TestCase {
	
	private Twitter tw;
	private List<Status> list = new ArrayList<Status>();
	private static final String id = "edipofederle";

	@Override
	protected void setUp() throws Exception {
		tw = new TwitterFactory().getInstance();
		super.setUp();
	}

	@Test
	public void testTwitterGetPagina1() throws TwitterException {
		list = tw.getUserTimeline(id, new Paging(1));
		assertEquals(20, list.size());
	}
	
	@Test
	public void testTwitterGetPagina2e3() throws TwitterException{
		list.clear();
		for(int i = 2;i<=3;i++){
			list.addAll(tw.getUserTimeline(id, new Paging(i)));
		}
		assertEquals(40, list.size());
	}
	
	@Test
	public void testTwitterGetPaginaMETODO()throws TwitterException{
		list.clear();
		list.addAll(MicroBlogging.obterTwittsDe(id, 4));
		list.addAll(MicroBlogging.obterTwittsDe(id, 5));
		list.addAll(MicroBlogging.obterTwittsDe(id, 6));
		assertEquals(60, list.size());
	}

	@Override
	protected void tearDown() throws Exception {
		list.clear();
		super.tearDown();
	}
}
